﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="ListOrganization.aspx.cs" Inherits="SD.Web.Views.Orgranization.ListOrganization" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script type="text/javascript">
    function Confirm_Active() {
        return confirm('Do you want to make this Organisation active ?');
    }
</script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentTitle" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Content" runat="server">
    <div class="grid740 simplebox">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
            
                <div class="titleh">
                    <h3 class="sorting_range">
                        <asp:LinkButton ID="LinkButtonAll" runat="server" CssClass="hg-blue" CommandName="all"
                            OnCommand="LinkLetter_Command" Text="All"></asp:LinkButton>
                        <asp:LinkButton ID="LinkButton09" runat="server" CommandName="0-1-2-3-4-5-6-7-8-9" OnCommand="LinkLetter_Command" Text="0-9"></asp:LinkButton>
                        <asp:LinkButton ID="LinkButtonAE" runat="server" CommandName="A B C D E" OnCommand="LinkLetter_Command" Text="A B C D E"></asp:LinkButton>
                        <asp:LinkButton ID="LinkButtonFJ" runat="server" CommandName="F G H I J" OnCommand="LinkLetter_Command" Text="F G H I J"></asp:LinkButton>
                        <asp:LinkButton ID="LinkButtonKN" runat="server" CommandName="K L M N" OnCommand="LinkLetter_Command" Text="K L M N"></asp:LinkButton>
                        <asp:LinkButton ID="LinkButtonOR" runat="server" CommandName="O P Q R" OnCommand="LinkLetter_Command" Text="O P Q R"></asp:LinkButton>
                        <asp:LinkButton ID="LinkButtonSV" runat="server" CommandName="S T U V" OnCommand="LinkLetter_Command" Text="S T U V"></asp:LinkButton>
                        <asp:LinkButton ID="LinkButtonWZ" runat="server" CommandName="W X Y Z" CssClass="last"
                            OnCommand="LinkLetter_Command" Text="W X Y Z"></asp:LinkButton>
                        <span class="right">
                            <asp:HyperLink ID="LinkCreate" runat="server" CssClass="hg-blue" NavigateUrl="#">Create</asp:HyperLink>
                            <asp:CheckBox ID="chkInactive" runat="server" Text="Include In-active" 
                            AutoPostBack="True" oncheckedchanged="chkInactive_CheckedChanged" />
                        </span>
                    </h3>
                </div>
                <div class="clear">
                </div>
                <asp:GridView ID="grvOrganization" CssClass="tablesorter" runat="server" AutoGenerateColumns="False"
                    AllowPaging="True" PageSize="15" AllowSorting="True" 
                    DataSourceID="ObjectDataSourceOrganization" 
                    onrowdatabound="grvOrganization_RowDataBound">
                    <Columns>
                        <asp:TemplateField HeaderText="Organization Name" SortExpression="OrganisationName">
                            <ItemTemplate>
                                <asp:LinkButton ID="LinkButtonOrganizationName" CausesValidation="false" runat="server" 
                                CommandName='<%# Eval("OrganizationId") %>' 
                                CommandArgument='<%#Eval("IsActive") %>'
                                OnClientClick='<%# !(bool)Eval("IsActive") ? "return Confirm_Active();" : string.Empty %>'
                                OnCommand="LinkButtonDepartmentName_Command"><%# Eval("OrganizationName")%>
                                    </asp:LinkButton>
                            </ItemTemplate>
                            <HeaderStyle CssClass="header" Width="133px"/>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Head Office Address Line 1" SortExpression="HeadOfficeAddressLine1">
                            <ItemTemplate>
                                <%#Eval("Address.AddressLine") %>
                            </ItemTemplate>
                            <HeaderStyle CssClass="header"/>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Postcode" SortExpression="PostCode">
                            <ItemTemplate>
                                <%#Eval("Address.PostCode") %>
                            </ItemTemplate>
                            <HeaderStyle CssClass="header" Width="120px"/>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Contact" SortExpression="Contact">
                            <ItemTemplate>
                                <%#string.Format("{0} {1}",Eval("Contact.FirstName"),Eval("Contact.Surname")) %>
                            </ItemTemplate>
                            <HeaderStyle CssClass="header" Width="137px"/>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Is Active?" SortExpression="IsActive">
                            <ItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%#(bool) Eval("IsActive") ? "Yes" :"No" %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle CssClass="header" Width="82px"/>
                        </asp:TemplateField>
                    </Columns>
                    <EmptyDataTemplate>
                        <blockquote>There are no items to show.</blockquote>
                    </EmptyDataTemplate>
                    <PagerStyle CssClass="pagination_table"></PagerStyle>
                </asp:GridView>
        <asp:ObjectDataSource ID="ObjectDataSourceOrganization" runat="server"
                    SelectCountMethod="CountOrganizations" EnablePaging="true"
                    MaximumRowsParameterName="maximumRows" 
                    StartRowIndexParameterName="startRowIndex"
                    SelectMethod="GetOrganizations" TypeName="SD.Business.OrganizationBUS" 
                    SortParameterName="sortType" 
                    onselecting="ObjectDataSourceOrganization_Selecting">
                    <SelectParameters>                        
                        <asp:Parameter DefaultValue="null" Name="filter" Type="Object" 
                            ConvertEmptyStringToNull="False" />

                    </SelectParameters>
                </asp:ObjectDataSource>        
            </ContentTemplate>
        </asp:UpdatePanel>
        
    </div>
</asp:Content>
